package com.zte.claa.inficombo.csa.app.service.huaxiapr.bean;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.zte.claa.inficombo.csa.app.util.JsonUtils;

/*
 * Author by 0283000106 
 */

@JsonInclude(JsonInclude.Include.NON_NULL)
public class HuaXiaRmRspWhiteNameList {
	private List<Map<String, String>> whitelist_data = new ArrayList<>();

	public List<Map<String, String>> getWhitelist_data() {
		return whitelist_data;
	}

	public void setWhitelist_data(List<Map<String, String>> whitelist_data) {
		this.whitelist_data = whitelist_data;
	}
	
	public Map<String, String> getWhiteName(int index){
		return whitelist_data.get(index);
	}
	
	public void addWhiteName(Map<String, String> whitename){
		Iterator<Map<String, String>> it = whitelist_data.iterator();
		boolean isexist = false;
		while(it.hasNext()){
			Map<String, String> x = it.next();
		    if(x.get("PlateNumber").equals(whitename.get("PlateNumber"))){
		        x = whitename;
		        isexist = true;
		    }
		}
		if(false == isexist){
			this.whitelist_data.add(whitename);
		}
	}
	
	public void removeWhiteName(String plateNum){
		Iterator<Map<String, String>> it = whitelist_data.iterator();
		while(it.hasNext()){
			Map<String, String> x = it.next();
		    if(x.get("PlateNumber").equals(plateNum)){
		        it.remove();
		    }
		}
	}
	
	public void clearWhiteList(){
//		Iterator<Map<String, String>> it = whitelist_data.iterator();
//		while(it.hasNext()){
//			Map<String, String> x = it.next();
//		    x.clear();
//		}
		whitelist_data.clear();
	}
	
	@Override
	public String toString() {
		String outputstr = JsonUtils.toJson(this);
		return outputstr;
	}
}
